﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Display.DialogUI {
    import flash.events.*;
    import flash.utils.*;
    import org.aswing.*;
    import Classes.*;
    import flash.text.*;
    import org.aswing.border.*;
    import Display.aswingui.*;
    import L10n.*;

    public class InputTextDialogView extends GenericDialogView {

        protected var m_inputLabel:String;
        protected var m_inputField:String;
        protected var m_textField:JTextField;

        public function InputTextDialogView(_arg1:Dictionary, _arg2:String, _arg3:String, _arg4:String, _arg5:String, _arg6:int=0, _arg7:Function=null, _arg8:String="", _arg9:int=0, _arg10:Function=null){
            this.m_inputLabel = _arg4;
            this.m_inputField = _arg5;
            super(_arg1, _arg2, _arg3, _arg6, _arg7, _arg8, _arg9, "", _arg10);
        }
        public function get textField():TextField{
            return ((this.m_textField) ? this.m_textField.getTextField() : null);
        }
        public function get text():String{
            return ((this.m_textField) ? this.m_textField.getText() : null);
        }
        override protected function createInteriorHolder():JPanel{
            var _local2:JPanel;
            var _local3:JPanel;
            var _local1:JPanel = new JPanel(new SoftBoxLayout(SoftBoxLayout.Y_AXIS, -10, SoftBoxLayout.CENTER));
            _local1.setPreferredWidth(m_bgAsset.width);
            _local1.setMinimumWidth(m_bgAsset.width);
            _local1.setMaximumWidth(m_bgAsset.width);
            _local2 = this.createHeaderPanel();
            ASwingHelper.prepare(_local2);
            textArea = createTextArea();
            ASwingHelper.prepare(textArea);
            _local1.setBorder(new EmptyBorder(null, new Insets(0, 0, 0, 0)));
            if (m_type != TYPE_NOBUTTONS){
                _local1.append(_local2);
            };
            _local1.append(ASwingHelper.verticalStrut(20));
            _local1.append(textArea);
            _local1.append(ASwingHelper.verticalStrut(BUTTON_MARGIN));
            if (((!((m_type == TYPE_MODAL))) && (!((m_type == TYPE_NOBUTTONS))))){
                _local3 = createButtonPanel();
                _local1.append(_local3);
            };
            ASwingHelper.prepare(_local1);
            return (_local1);
        }
        override protected function createHeaderPanel():JPanel{
            var _local1:JPanel = new JPanel(new BorderLayout());
            var _local2:JPanel = createCloseButtonPanel();
            var _local3:JPanel = this.createTitlePanel();
            ASwingHelper.prepare(_local2);
            _local1.append(ASwingHelper.horizontalStrut(_local2.getWidth()), BorderLayout.WEST);
            _local1.append(_local3, BorderLayout.CENTER);
            _local1.append(_local2, BorderLayout.EAST);
            ASwingHelper.setEasyBorder(_local1, 55, 0, 20);
            return (_local1);
        }
        override protected function makeBackground():void{
            var _local1:MarginBackground;
            if (m_bgAsset){
                _local1 = new MarginBackground(m_bgAsset, new Insets(0, 0, 10, 0));
                this.setBackgroundDecorator(_local1);
                this.setPreferredWidth(m_bgAsset.width);
                this.setMinimumWidth(m_bgAsset.width);
                this.setMaximumWidth(m_bgAsset.width);
            };
        }
        override protected function createTextAreaInnerPane(_arg1:Component):JPanel{
            var _local2:JPanel = super.createTextAreaInnerPane(_arg1);
            var _local3:JTextField = this.createTextField();
            var _local4:Component = this.createTextFieldLabel();
            var _local5:Component = this.createTextFieldContainer(_local3);
            var _local6:Component = this.createTextFieldContainer(_local4);
            _local3.addEventListener(TextEvent.TEXT_INPUT, this.textInput);
            this.m_textField = _local3;
            _local2.append(ASwingHelper.verticalStrut(15));
            _local2.append(_local6);
            _local2.append(_local5);
            _local2.append(ASwingHelper.verticalStrut(9));
            return (_local2);
        }
        override protected function setMessageTextWidth(_arg1:Boolean=false):Number{
            return (430);
        }
        override protected function createTextComponent(_arg1:Number):Component{
            var _local2:Component = ASwingHelper.makeMultilineText(m_message, _arg1, EmbeddedArt.DEFAULT_FONT_NAME_BOLD, TextFormatAlign.CENTER, 16, 10582366);
            _local2.setBorder(new EmptyBorder(null, new Insets(0, 20, 0, 20)));
            return (_local2);
        }
        override protected function createTitlePanel():JPanel{
            m_titleFontSize = 28;
            return (super.createTitlePanel());
        }
        protected function createTextField():JTextField{
            var _local1:JTextField = ASwingHelper.makeTextField(this.m_inputField, EmbeddedArt.DEFAULT_SERIF_FONT, 16, 0x666666);
            _local1.setEditable(true);
            _local1.setFont(new ASFont("_sans", 16, false, false, false));
            _local1.getTextField().selectable = true;
            _local1.setBackground(ASwingHelper.getWhite());
            _local1.setBorder(new LineBorder(null, new ASColor(15128239), 1));
            _local1.setPreferredWidth(250);
            if (LocaleHelper.localSetting.sns.input_textfield_select_all){
                _local1.getTextField().addEventListener(MouseEvent.MOUSE_UP, this.highlightCurrentText, false, 0, true);
            };
            return (_local1);
        }
        protected function createTextFieldContainer(_arg1:Component):Component{
            var _local2:JPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 0));
            _local2.append(_arg1);
            return (_local2);
        }
        protected function createTextFieldLabel():Component{
            var _local1:JLabel = ASwingHelper.makeLabel(this.m_inputLabel, EmbeddedArt.DEFAULT_FONT_NAME_BOLD, 16, 10582366);
            _local1.setBorder(new EmptyBorder(null, new Insets(0, -2, 0, 0)));
            return (_local1);
        }
        private function highlightCurrentText(_arg1:MouseEvent):void{
            var _local2:TextField = (_arg1.target as TextField);
            if (_local2){
                _local2.setSelection(0, _local2.text.length);
            };
        }
        protected function textInput(_arg1:TextEvent):void{
            var _local2:String = Global.gameSettings.getString("inavlidNameCharacters");
            var _local3:String = _arg1.text;
            var _local4:int;
            while (_local4 < _local2.length) {
                if (_local3 == _local2.substr(_local4, 1)){
                    _arg1.preventDefault();
                };
                _local4++;
            };
        }

    }
}//package Display.DialogUI 
